/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package view;

import com.sun.lwuit.Form;
import com.sun.lwuit.TextArea;
import com.sun.lwuit.Command;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;
import com.sun.lwuit.layouts.BorderLayout;
import com.sun.lwuit.layouts.BoxLayout;
import view.additional.ChernovtsiCreator;
import view.additional.Creator;
import view.additional.DefaultCreator;

/**
 *
 * @author Kvest
 */
public class ArchiveDetails  extends Form implements ActionListener
{
    public static final int EMPTY_ID = 0;
    public static final int BACK_ID = 1;

    private Command back;
    private FormAction listener;

    private Creator creator;

    public ArchiveDetails(FormAction listener)
    {
        super("Детали заказа");
        this.listener = listener;
        if (ViewManager.getViewManager().getFunctionMenuType() == FunctionMenu.CHERNOVTSI_TYPE)
        {
            creator = new ChernovtsiCreator(this, true);
        }
        else
        {
            creator = new DefaultCreator(this);
        }

        init();
    }

    private void init()
    {
        setLayout(new BoxLayout(BoxLayout.Y_AXIS));

        addCommandListener(this);

        addCommand(new Command("", EMPTY_ID));
        back= new Command("Назад", BACK_ID);
        addCommand(back);

        creator.init(); 
    }

    public void setText(String value)
    {
        creator.setText(value);
    }

    public void actionPerformed(ActionEvent evt)
    {
        if (listener != null)
        {
            listener.commandAction(evt.getCommand().getId());
        }
    }
}
